package com.example.springboot.service.impl;

import com.example.springboot.controller.request.RecordPageRequest;
import com.example.springboot.entity.Record;
import com.example.springboot.entity.Record;
import com.example.springboot.entity.Record;
import com.example.springboot.mapper.RecordMapper;
import com.example.springboot.service.IRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecordService implements IRecordService {

    @Autowired
    RecordMapper recordMapper;

    @Override
    public List<Record> listRecords() {
        return recordMapper.listRecoreds();
    }

    @Override
    public Object page(RecordPageRequest recordPageRequest) {
        PageHelper.startPage(recordPageRequest.getPageNum(), recordPageRequest.getPageSize());
        List<Record> records = recordMapper.listByCondition(recordPageRequest);
        return new PageInfo<>(records);
    }

    public void add(Record record) {
        recordMapper.add(record);
    }
}
